#!/usr/bin/env python
#-*- coding: utf-8 -*-
#@Time:2020/7/8 11:00 上午
#@Author:boyizhang
"""
目标：1、搜索组装测试套件
      2、指定报告存放路径及文件名称
      3、运行测试套件并生成测试报告（使用HTMLTestRunner)
"""
import unittest
import time
from HTMLTestRunner import HTMLTestRunner
# from test import HTMLTestRunner

# from case.test_login import TestLogin
def test():

    #组装测试套件
    suite=unittest.defaultTestLoader.discover('./case/',pattern='test_api_*.py')
    # suite = unittest.TestSuite()
    # suite.addTest(TestLogin('test_login'))
    #指定报告存放路径及文件名称
    file_path="./report/{}.html".format(time.strftime("%Y_%m_%d %H_%M_%S"))
    #运行测试套件并生成测试报告

    with open(file_path,"bw") as f:
        HTMLTestRunner(stream=f, title='报告标题', description='报告说明').run(suite)
test()
#
# if __name__ == '__main__':
#    runner = unittest.TextTestRunner(verbosity=2)
#    runner.run(suite)